package com.jy.adscm.hcPlan.config;

import com.jy.adscm.hcPlan.service.HcPlanFinalAssemblyService;
import com.jy.adscm.utils.AdscmDateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.Date;

/**
 * @author yyy
 * @ClassName HcPlanTimer
 * @Description 定时器
 * @date 2018/9/14 16:11
 */
@Configuration          //证明这个类是一个配置文件
@EnableScheduling       //打开quartz定时器总开关
public class HcPlanTimer {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    HcPlanFinalAssemblyService hcPlanFinalAssemblyService;


    @Scheduled(cron = "0 0 22 * * ? ")
    public void timer(){
        logger.info("定时任务：根据已有销售任务，生成总装数据...");
        try{
            hcPlanFinalAssemblyService.loadFinalAssembly(AdscmDateUtils.getNowOnlyDateFomat1(new Date()));
        }catch (Exception e){
            logger.error("执行定时任务：根据已有销售任务，生成总装数据 异常",e);
        }
    }


}
